﻿@{
    ViewBag.Title = "网站管理平台_上传产品图片";
}

@section HeadContent
{
    <script type="text/javascript">
        var onUploadSuccess = function (response, data) {
            App.UploadedMsg.setText("图片上传成功，可继续上传。");
        };
    </script>
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().FormPanel()
            .ID("FormPanel1")
            .Layout("fit")
            .Items(
                Html.X().Panel()
                    .Border(false)
                    .Padding(5)
                    .Layout("form")
                    .Defaults(
                        Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                    )
                    .Items(
                        Html.X().Hidden().ID("ProductID").Text(ViewData["ProductID"].ToString()),
                        Html.X().TextField().ID("Title").FieldLabel("图片标题").AllowBlank(false).MaxLength(50),
                        Html.X().FileUploadField().ID("ProductImage").FieldLabel("产品图片").Icon(Icon.ImageAdd).ButtonText(""),
                        Html.X().NumberField().ID("SortNum").FieldLabel("序号"),
                        Html.X().TextField().ID("Description").FieldLabel("描述").MaxLength(200),
                        Html.X().Label().ID("UploadedMsg").StyleSpec("color:blue")
                    )
            )
            .TopBar(
                Html.X().Toolbar().Items(
                    Html.X().Button().Text("保存").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "UploadProductImg";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在保存";
                            de.Click.Success = "onUploadSuccess";
                            de.Click.Failure = "ext.net.comjs.onSubmitFailure";
                        })
                        .Listeners(ls =>
                        {
                            ls.Click.Handler = "return ext.net.comjs.onFormSubmit()";
                        })
                )
            )
            .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                .Listeners(ls => ls.ValidityChange.Handler = "ext.net.comjs.setFormStatusBar(this, valid)")
    )
)